package ar.edu.unq.leezsi.core;

import java.util.HashMap;
import java.util.Map;

import ar.edu.unq.leezsi.html.Page;
import ar.edu.unq.leezsi.utils.ClassUtils;

public class SimpleURLMapper implements URLMapper {
	private final Map<String, Page<?>> pages = new HashMap<String, Page<?>>();

	@Override
	public Page<?> get(String url) {
		return this.getPages().get(url);
	}

	public Map<String, Page<?>> getPages() {
		return this.pages;
	}

	@Override
	public boolean isMapped(String url) {
		return this.getPages().containsKey(url);
	}

	@Override
	public void map(String url, Class<? extends Page<?>> page, Object[] params) {
		this.map(url, ClassUtils.newInstance(page, params));
	}

	@Override
	public void map(String url, Page<?> page) {
		this.getPages().put(url, page);

	}

}
